package com.estun.backroundManagementService.enums;

/**
 * 优先级枚举类
 */
public enum PriorityEnum {
    UNKNOWN("-1", "未知"),
    GENERAL("50", "一般"),
    URGENT("40", "加急"),
    EMERGENCY("30", "紧急");

    private final String code;
    private final String description;

    PriorityEnum(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据优先级代码获取枚举值
     *
     * @param code 优先级代码
     * @return 对应的枚举值，如果没有匹配项返回 null
     */
    public static PriorityEnum getByCode(String code) {
        for (PriorityEnum priority : PriorityEnum.values()) {
            if (priority.getCode().equals(code)) {
                return priority;
            }
        }
        return UNKNOWN;
    }
}
